<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes"/>
<title>C3讲解-24航C | pansis.io</title>
<link rel="shortcut icon" href="https://github.pansis.site/favicon.ico">
<link href="https://github.pansis.site/styles/main.css" rel="stylesheet">
<link href="//at.alicdn.com/t/c/font_1678829_b85ccgkdqkr.css" rel="stylesheet">
<link href="//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.10.0/katex.min.css" rel="stylesheet">
<link rel="alternate" type="application/rss+xml" title="pansis.io » Feed" href="https://github.pansis.site/atom.xml">
        <meta name="description" content="A Firefly小姐的水题
题解
#include&lt;stdio.h&gt;

int main()
{
    unsigned int a,b;
    scanf(&quot;%u%u&quot;,&amp;a,&amp;b);..." />
        <meta name="keywords" content="24航C" />
        <!-- OG -->
        <meta property="og:locale" content="zh_CN">
        <meta property="og:title" content="C3讲解-24航C" />
        <meta property="og:type" content="article" />
        <meta property="og:description" content="A Firefly小姐的水题
题解
#include&amp;lt;stdio.h&amp;gt;

int main()
{
    unsigned int a,b;
    scanf(&amp;quot;%u%u&amp;quot;,&amp;amp;a,&amp;amp;b);...">
        <meta property="og:url" content="https://github.pansis.site/post/C3讲解-24航C/" />
        <meta property="og:site_name" content="pansis.io">
        <meta property="og:updated_time" content="2024-10-10">
        <meta property="og:image" content="" />
        <meta property="og:image:secure_url" content="">
        <meta property="og:image:alt" content="C3讲解-24航C">
        <!-- Twitter (post.ejs) -->
        <meta name="twitter:card" content="summary_large_image">
        <meta name="twitter:title" content="C3讲解-24航C">
        <meta name="twitter:description" content="A Firefly小姐的水题
题解
#include&amp;lt;stdio.h&amp;gt;

int main()
{
    unsigned int a,b;
    scanf(&amp;quot;%u%u&amp;quot;,&amp;amp;a,&amp;amp;b);...">
        <!-- <meta name="twitter:site" content="@WBoy0609">
        <meta name="twitter:creator" content="@WBoy0609"> -->
        <meta name="twitter:image" content="">
</head>

<body>
    <div class="main animated">
        <div class="header animated fadeInDown">
    <div class="site_title_container">
        <div class="site_title">
            <a href="https://github.pansis.site">pansis.io</a>
        </div>
    </div>
    <div class="my_socials">
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
        <a href="https://github.pansis.site/atom.xml" title="rss" target="_blank"><i class="iconfont icon-rss"></i></a>
    </div>
</div>

    <div class="header_menu">
        
            
                <a href="/" class="menu">首页</a>
            
        
            
                <a href="/tag/GWAaV2nvk/" class="menu">程序设计课程</a>
            
        
            
                <a href="/tag/24hangc" class="menu">比赛</a>
            
        
            
                <a href="/tag/L7r9STb75/" class="menu">Python教程</a>
            
        
            
                <a href="/tags" class="menu">分类</a>
            
        
        <div class="gridea-search-div">
            <form id="gridea-search-form" action="https://github.pansis.site/search/">
                <input class="gridea-search-input" autocomplete="off" spellcheck="false" name="q"/>
            </form>
        </div>
    </div>

            <div class="autopagerize_page_element">
                <div class="content">
                    <div class="post_page">
                        <div class="post animated fadeInDown">
                            <div class="post_title post_detail_title">
                                <h2>
                                    C3讲解-24航C
                                </h2>
                                <span class="article-info">
                                    2024-10-10, 642 words, 4 min read
                                </span>
                            </div>
                            <div class="post_content markdown">
                                <p class="md_block">
                                    <span class="md_line md_line_start md_line_end">
                                        <h1 id="a-firefly小姐的水题"><code>A</code> Firefly小姐的水题</h1>
<h4 id="题解">题解</h4>
<pre><code class="language-c">#include&lt;stdio.h&gt;

int main()
{
    unsigned int a,b;
    scanf(&quot;%u%u&quot;,&amp;a,&amp;b);
    printf(&quot;%u&quot;,a&amp;b);
    

}
</code></pre>
<h4 id="位运算符">位运算符</h4>
<pre><code>&amp;按位与  |按位或  ^按位异或  ~取反  &lt;&lt;左移  &gt;&gt;右移
</code></pre>
<pre><code>按位与
A  B  A&amp;B
1  1   1
0  1   0
1  0   0
0  0   0
</code></pre>
<pre><code>按位或
A  B  A|B
1  1   1
0  1   1
1  0   1
0  0   0
</code></pre>
<pre><code>按位异或
A  B  A^B
1  1   0
0  1   1
1  0   1
0  0   0
</code></pre>
<pre><code>按位取反~
1变0,0变1
</code></pre>
<h1 id="b-你是谁"><code>B</code> 你是谁</h1>
<h4 id="对某一位置1按位或-n1x-n110100">对某一位置1：按位或 n|(1&lt;&lt;x)  n=110100</h4>
<p>10110   00101  00001</p>
<h4 id="对某一位置0按位与-n~1x">对某一位置0：按位与 n&amp;(~(1&lt;&lt;x))</h4>
<h4 id="判定某一位的值nx1">判定某一位的值：(n&gt;&gt;x)&amp;1</h4>
<p>1、左移右移时注意移位范围</p>
<p>1&lt;&lt;35=0  错误<br>
1ll&lt;&lt;35=<span class="katex"><span class="katex-mathml"><math><semantics><mrow><msup><mn>2</mn><mn>35</mn></msup></mrow><annotation encoding="application/x-tex">2^{35}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8141079999999999em;vertical-align:0em;"></span><span class="mord"><span class="mord">2</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141079999999999em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">3</span><span class="mord mtight">5</span></span></span></span></span></span></span></span></span></span></span></span></p>
<p>2、表示某个变量的补码</p>
<p>计算机存储的值均以补码的方式存储，提取补码时不需要对原值进行任何转换。</p>
<ul>
<li>正数的补码就是其本身的二进制值。</li>
<li>负数的补码是本身二进制值取反加1。</li>
</ul>
<pre><code class="language-c">#include &lt;stdio.h&gt;
int main()
{
    int n;
    scanf(&quot;%d&quot;,&amp;n);
    for (int i = 31; i &gt;=0; --i) {
        printf(&quot;%d&quot;,(n&gt;&gt;i)&amp;1);
    }

}
</code></pre>
<h1 id="c-firefly小姐的位运算大练习入门版"><code>C</code> Firefly小姐的位运算大练习—入门版</h1>
<h4 id="题解-2">题解</h4>
<pre><code class="language-c">#include&lt;stdio.h&gt;

int main()
{
    unsigned int n;
    int x;
    int t;
    scanf(&quot;%d&quot;,&amp;t);
    for (int i = 0; i &lt; t; ++i) {
        scanf(&quot;%u%d&quot;,&amp;n,&amp;x);
        printf(&quot;%d\n&quot;,(n&gt;&gt;x)&amp;1);
    }


}
</code></pre>
<h1 id="c-firefly小姐的位运算大练习入门版-2"><code>C</code> Firefly小姐的位运算大练习—入门版</h1>
<h4 id="题解-3">题解</h4>
<pre><code class="language-c">#include&lt;stdio.h&gt;

int main()
{
    int n;
    scanf(&quot;%d&quot;,&amp;n);
    for (int i = 0; i &lt; n; ++i) {
        unsigned int a,l;
        int op;
        scanf(&quot;%d&quot;,&amp;op);
        if (op==1)
        {
            scanf(&quot;%u&quot;,&amp;a);
            printf(&quot;%u\n&quot;,~a);
        }
        else if (op==2)
        {
            scanf(&quot;%u%u&quot;,&amp;a,&amp;l);
            printf(&quot;%u\n&quot;,a&lt;&lt;l);
        }
        else
        {
            scanf(&quot;%u%u&quot;,&amp;a,&amp;l);
            printf(&quot;%u\n&quot;,a&gt;&gt;l);
        }

    }


}
</code></pre>
<h1 id="d-cancanneed真值表"><code>D</code> cancanneed真值表</h1>
<h4 id="题解-4">题解</h4>
<pre><code class="language-c">#include&lt;stdio.h&gt;

int main()
{
    unsigned int a,b;
    while (scanf(&quot;%u%u&quot;,&amp;a,&amp;b)!=EOF)
    {
        printf(&quot;%u\n&quot;,(~a)&amp;b);
    }



}
</code></pre>
<h1 id="e-小牛与内存压缩"><code>E</code> 小牛与内存压缩</h1>
<h4 id="题解-5">题解</h4>
<pre><code class="language-c">#include&lt;stdio.h&gt;

int main()
{
    unsigned int a,b;
    while (scanf(&quot;%u%u&quot;,&amp;a,&amp;b)!=EOF)
    {
        printf(&quot;%u\n&quot;,(~a)&amp;b);
    }



}
</code></pre>
<h1 id="f-一位全加器先生"><code>F</code> 一位全加器先生</h1>
<pre><code class="language-c">
#include&lt;stdio.h&gt;

int main()
{
    int a,b,c;
    scanf(&quot;%d%d%d&quot;,&amp;a,&amp;b,&amp;c);
    int fa=~a,fb=~b,fc=~c;
    int s=((fa&amp;fb&amp;c)|(fa&amp;b&amp;fc)|(a&amp;fb&amp;fc)|(a&amp;b&amp;c))&amp;1;
    int cc=((a&amp;c)|(b&amp;c)|(a&amp;b))&amp;1;
    printf(&quot;%d %d&quot;,s,cc);




}
</code></pre>
<br />
                                            
                                </p>
                            </div>
                            <div class="post_footer">
                                
                                    <div class="meta">
                                        <div class="info"><span class="field tags"><i class="iconfont icon-tag-sm"></i>
                                                
                                                    <a href="https://github.pansis.site/tag/24hangc/" class="article-info">
                                                        24航C
                                                    </a>
                                                    
                                            </span>
                                        </div>
                                    </div>
                                    
                                        
                                            <div class="next-post" style="margin-top: 20px;">
                                                <div class="next">下一篇</div>
                                                <a href="https://github.pansis.site/post/C3 - Solution-24航C/">
                                                    <h3 class="post-title">
                                                        C3 - Solution-24航C
                                                    </h3>
                                                </a>
                                            </div>
                                            
                            </div>
                        </div>
                        
                            
                                <link rel="stylesheet" href="https://unpkg.com/gitalk/dist/gitalk.css">
<script src="https://unpkg.com/gitalk/dist/gitalk.min.js"></script>
<div id="gitalk-container" style="padding-bottom: 20px;"></div>
<script>
    var pageId = (location.pathname).substring(1, 49) // Ensure uniqueness and length less than 50
    pageId = pageId.endsWith('/') ? pageId.slice(0, -1) : pageId // 以斜杠结尾则去除
    var gitalk = new Gitalk({
        clientID: '9d5eba33618472c44a07',
        clientSecret: '065a85ed04333ceebfc4f01d7ca1674175730339',
        repo: 'fzxl2003.github.io',
        owner: 'fzxl2003',
        admin: ['fzxl2003'],
        id: pageId,
        distractionFreeMode: false  // Facebook-like distraction free mode
    })
    gitalk.render('gitalk-container')
</script>
                                    
                                        
                                                    
                    </div>
                </div>
            </div>
    </div>
    <div class="footer">
    
    <div class="powered_by">
        <a href="https://codeberg.org/kytrun/gridea-theme-one" target="_blank">Theme One,</a>
        <a href="https://open.gridea.dev/" target="_blank">Powered by Gridea&#65281;</a>
    </div>
    
    
        <div class="footer_slogan">
            Powered by <a href="https://github.com/getgridea/gridea" target="_blank">Gridea</a>
        </div>
    
    <div id="back_to_top" class="back_to_top">
        <span>△</span>
    </div>
    
</div>

<script src="https://github.pansis.site/media/scripts/util.js"></script>
        <link rel="stylesheet" href="//unpkg.com/@highlightjs/cdn-assets@11.5.1/styles/default.min.css">
        <script src="//unpkg.com/@highlightjs/cdn-assets@11.5.1/highlight.min.js"></script>
        <script>hljs.highlightAll();</script>
</body>

</html>